<?php
  session_start();

if(!isset($_SESSION['id'])){
	header('Location:login.php');
}
 $arrayid=$_POST['arrayid'];
 $id=$_POST['id'];
 $connection=mysql_connect("localhost","root","");
 mysql_select_db("shenji",$connection);
 mysql_query("set names utf8");
 
 if(isset($id)){
	 $sql="select * from other_jiekou where id=$id";
	 $result=mysql_query($sql);
	 $row=mysql_fetch_array($result);
	 $licesneid=$row['licesneid'];
	 $beizhu=$row['beizhu'];
	 $typeid=$row['typeid'];


	 $sql="insert into jiekou(licesneid,beizhu,typeid) value('$licesneid','$beizhu','$typeid')";	
	 if(mysql_query($sql,$connection)){ //说明没有重复需要入库
		 echo 1;
	 }else{
		 echo 0;
	 }
	 

	 //删除现在的
	 $sql2="delete from other_jiekou where id=$id";
	 mysql_query($sql2);
 }

 //处理大量的
 if(isset($arrayid[0])){
	 
	  foreach ($arrayid as $id){
         $sql="select * from other_jiekou where id=$id";
		 $result=mysql_query($sql);
		 $row=mysql_fetch_array($result);
		 $licesneid=$row['licesneid'];
		 $beizhu=$row['beizhu'];
		 $typeid=$row['typeid'];
		 $sql="insert into jiekou(licesneid,beizhu,typeid) value('$licesneid','$beizhu','$typeid')";
		 mysql_query($sql);
		 
		 //删除现在的
		 $sql2="delete from other_jiekou where id=$id";
		 mysql_query($sql2);
	  }
	 
	 
 }
 
 

?>